package com.gzw.scm.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.gzw.scm.R;

import java.util.List;

/**
 * Created by gaozhiwei on 2015/10/10.
 */
public class MainGVAdapter extends BaseAdapter {
    private Context mContext;
    private List<String> nameList;

    public MainGVAdapter(Context _mContext, List<String> _nameList) {
        mContext = _mContext;
        nameList = _nameList;
    }

    @Override
    public int getCount() {
        return nameList.size();
    }

    @Override
    public Object getItem(int position) {

        return nameList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder mHolder = null;
        if (convertView == null) {
            convertView = View
                    .inflate(mContext, R.layout.item_gv_main, null);
            mHolder = new Holder(convertView);
            convertView.setTag(mHolder);
        } else {
            mHolder = (Holder) convertView.getTag();
        }

      switch (nameList.get(position)){
          case "zb-fp":
              mHolder.iv.setImageResource(R.mipmap.a1);
              break;
          case "fb-js":
              mHolder.iv.setImageResource(R.mipmap.b1);
              break;
          case "fb-dbjs":
              mHolder.iv.setImageResource(R.mipmap.dbjs);
              break;
          case "fb-dbfc":
              mHolder.iv.setImageResource(R.mipmap.dbfc);
              break;
          case "fb-nbdb":
              mHolder.iv.setImageResource(R.mipmap.b4);
              break;
          case "fb-wx":
              mHolder.iv.setImageResource(R.mipmap.b5);
              break;
          case "fb-fc":
              mHolder.iv.setImageResource(R.mipmap.b6);
              break;
          case "rdc-zxjs":
              mHolder.iv.setImageResource(R.mipmap.c1);
              break;
          case "rdc-nxjs":
              mHolder.iv.setImageResource(R.mipmap.c2);
              break;
          case "rdc-ck":
              mHolder.iv.setImageResource(R.mipmap.c3);
              break;
          case "rdc-fhzx":
              mHolder.iv.setImageResource(R.mipmap.c4);
              break;
          case "rdc-bd":
              mHolder.iv.setImageResource(R.mipmap.bangding);
              break;
          case "rdc-bb":
              mHolder.iv.setImageResource(R.mipmap.bubang);
              break;
          case "rdc-pd":
              mHolder.iv.setImageResource(R.mipmap.pandian);
              break;
          case "rdc-jb":
              mHolder.iv.setImageResource(R.mipmap.jiebang);
              break;
          case "rdc-yjck":
              mHolder.iv.setImageResource(R.mipmap.yjck);
              break;
      }

        return convertView;
    }
    static class Holder {
//        private TextView tvName;
        private ImageView iv;
        public Holder(View view) {
//            tvName = (TextView) view.findViewById(R.id.tv_name);
            iv=(ImageView)view.findViewById(R.id.iv);
        }
//        public TextView getTvName() {
//            return tvName;
//        }
        public ImageView getIv(){
            return iv;
        }
    }
}
